<!-- diaWidth  对话框的宽度  单位%-->
<!-- showDialog  对话框是否显示 -->
<!-- diaTop  对话框对屏幕上方的距离  单位vh-->
<!-- titleLeft  对话框头部左侧的margin   单位px-->
<!-- headerName  对话框头部文字 -->
<!-- smallTitle  对话框头部小文字 -->
<!-- backLetter  取消-字-->
<!-- saveLetter  确定-字 -->
<!-- save  确定按钮事件 -->
<!-- footerTop  底部按钮距离上侧距离  单位px-->

<template>
  <div class="dialog">
    <el-dialog
      @close="closeDialog"
      :width="diaWidth + '%'"
      :model-value="showDialog"
      :close-on-click-modal="false"
      :top="diaTop + 'vh'"
    >
      <template #header>
        <h3 class="dia-header" :style="{ marginLeft: titleLeft + 'px' }">
          {{ headerName }}
          <img
            @click="closeDialog"
            class="img"
            src="@/assets/images/layout/chahao.png"
            alt=""
          />
        </h3>
      </template>
      <slot name="content" />
      <footer
        class="footer"
        :style="{
          marginTop: footerTop + 'px',
          marginBottom: footerBottom + 'px',
          padding: footerPadding + 'px',
        }"
        v-if="footerShow"
      >
        <div class="save" @click="save">
          <button>{{ saveLetter }}</button>
        </div>
        <div class="back" @click="closeDialog">
          <button>{{ backLetter }}</button>
        </div>
      </footer>
    </el-dialog>
  </div>
</template>
<script setup lang="ts">
defineProps({
  headerName: {
    type: String,
  },
  showDialog: {
    type: Boolean,
  },
  titleLeft: {
    type: String,
    default: "43",
  },
  footerBottom: {
    default: "10",
  },
  footerShow: {
    default: true,
  },
  diaWidth: {
    type: String,
    default: "40",
  },
  diaTop: {
    type: String,
    default: "6",
  },
  backLetter: {
    type: String,
    default: "返回",
  },
  saveLetter: {
    type: String,
    default: "确定",
  },
  footerPadding: {
    default: "0 100",
  },
  smallTitle: {
    type: String,
  },
  footerTop: {
    type: String,
    default: "40",
  },
});
let num = ref(1);
let $emit = defineEmits(["update:showDialog", "save", "close"]);
let closeDialog = () => {
  if (num.value == 2) {
    return;
  }
  $emit("close", false);
  $emit("update:showDialog", false);
  num.value = 2;
  setTimeout(() => {
    num.value = 1;
  }, 0);
};
let save = () => {
  $emit("save");
};
// let autoClose = () => {
//   $emit("close", false);
//   $emit("update:showDialog", false);
// };
</script>
<style scoped lang="scss">
.dialog {
  :deep(.el-input) {
    width: 100%;
  }

  :deep(.el-select) {
    width: 100%;
  }
  :deep(.el-input__inner::placeholder) {
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 18px;
    color: #ffffff;
  }
  :deep(.el-input__inner) {
    font-weight: 400;
    font-size: 18px;
    color: #ffffff;
  }
  :deep(.el-form-item__label) {
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 20px !important;
    color: #ffffff;
  }
  :deep(.el-date-editor.el-input, .el-date-editor.el-input__wrapper) {
    width: 100%;
  }

  :deep(.el-textarea__inner) {
    background-color: #012046;
    font-weight: 400;
    font-size: 18px;
    color: #ffffff;
    box-shadow: none;
    border: 1px solid #61c8ff;
  }
  :deep(.el-input__wrapper) {
    width: 100%;
    height: 35px;
    background-color: #235b87;
    box-shadow: none !important;
    border: 1px solid #61c8ff;
  }

  :deep(.el-dialog) {
    border: 1px solid #61c8ff;
    border-radius: 10px;
    .el-dialog__header {
      width: 100%;
      display: flex;
      justify-content: space-between;
      height: 49px;
      background: #012046;
      border-radius: 10px 10px 0px 0px;
      padding: 6px 8px 0 8px !important;
    }
    .el-dialog__body {
      background-repeat: no-repeat;
      background-size: 100% 100%;
      background-color: #012046;
      border-bottom-left-radius: 10px;
      border-bottom-right-radius: 10px;
      padding-top: 2px;
    }
    .el-dialog__headerbtn {
      display: none;
    }
    .dia-header {
      font-family: Source Han Sans CN;
      font-weight: 500;
      font-size: 26px;
      height: 49px;
      color: #ffffff;
      width: 100%;
      line-height: 49px;
      background: #044483;
      padding-left: 27px;
      border-radius: 10px 10px 0px 0px;
      margin: 0 !important;
      position: relative;
      .img {
        width: 18px;
        height: 18px;
        position: absolute;
        cursor: pointer;
        right: 35px;
        top: 50%;
        transform: translateY(-50%);
      }
    }

    .el-form {
      margin-top: 20px;
    }
    .footer {
      display: flex;
      justify-content: space-around;
      width: 100%;
      .back {
        background-image: url("@/assets/images/components/cancel-bgc.png");
        background-size: cover;
        background-repeat: no-repeat;
        width: 148px;
        height: 49px;
      }
      .save {
        background-image: url("@/assets/images/components/save-btn.png");
        background-size: cover;
        background-repeat: no-repeat;
        width: 148px;
        height: 49px;
      }
      .back,
      .save {
        display: flex;
        justify-content: center;
        cursor: pointer;
        align-items: center;

        button {
          font-size: 20px;
          font-weight: 400;
          color: #ffffff;
          border: none;
          background-color: transparent !important;
          cursor: pointer;
          margin-bottom: 4px;
        }
      }
      .save {
        margin-left: 49px;
      }
    }
    .el-form-item__label {
      color: #fff;
      font-size: 24px;
      font-weight: 400;
    }
  }
}
</style>
